package main

import "fmt"

type Liters float64
type Gallons float64
type Title string

func main() {
	carFuel := Gallons(10.0)
	busFuel := Liters(240.0)
	// 变量使用已定义的类型后，不能把另一个类型赋给它
	//busFuel = Gallons(10.0)
	//carFuel = Liters(240.0)
	fmt.Println(carFuel, busFuel)
	fmt.Println(Gallons(1.2) + Gallons(3.4))
	fmt.Println(Title("Changsha") + " NB")
	fmt.Println(Title("Changsha") == "Changsha")
	carFuel += toGallons(Liters(40.0))
	busFuel += toLiters(Gallons(30.0))
	fmt.Printf("Car fuel: %0.1f gallons\nBus fuel: %0.1f liters\n", carFuel, busFuel)
}

func toGallons(l Liters) Gallons {
	return Gallons(l * 0.264)
}

func toLiters(g Gallons) Liters {
	return Liters(g * 3.785)
}
